class A_ALG{ETP,ATP<$ARR{ETP}}
****
Miscellaneous array algorithms Usage:
_____a:_ARRAY{FLT}_:=_|1.0,2.0,3.0,3.0|;
_____a_alg:_A_ALG{INT,ARRAY{INT}};_--_dummy_variable
_____Counting_3s_in_the_array
_______number_of_threes:_INT_:=_a_alg.count(a,3.0);
_____Getting_an_array_of_indices
_______index_array:ARRAY{INT}_:=_a_alg.inds(a);


Flattened version is here

Ancestors
COMPARE{_}



Public


Features
count(a: ATP,v:ETP):INT
**** The number of elements that are `elt_eq' to `v'.
equals(a: ATP,e: $ARR{ETP}): BOOL
**** Returns true if all of "e"'s elements are equal to a's elts
inds(a: ATP): ARRAY{INT}
**** Return an index array which is the same size as self and is set to the values of the indices
map(a: ATP,r:ROUT{ETP}:ETP)
**** Set each element of self to the result of applying `r' to it.
mismatch(a:ATP,pattern: ARRAY{ETP}):INT
**** The index of the first element of self which differs from `a'. -1 if self is a prefix of `a' or self is void.
reduce(a:ATP, r:ROUT{ETP,ETP}:ETP, start_value:ETP) :ETP
**** Combine all the elements of self by applying `r' over elements in the order determined by ind!
replace(a: ATP, old_elt,new_replacement: ETP)
**** Replace elements that are `elt_eq' to `o' by `n' wherever it occurs
replace_if(a: ATP,test: ROUT{ETP}:BOOL,replacement_value: ETP)
scan(a:ATP, r:ROUT{ETP,ETP}:ETP, start_value:ETP)
**** Set each element in a to the result of applying `r' left to right to the array up to the element. The first element is left unchanged.
str(a: ATP): STR
**** Prints out a string version of the array of the components that are under $STR, and their associated indices


Private

elt_str(e: ETP,i: INT): STR

The Sather Home Page